<?php

namespace Biz\model\course;

use Doraemon\pockets\datebase\BaseDbModel;

class CourseOrderLog extends BaseDbModel
{

    const _CONFIG_FILE_ = 'db_course';

    const _CONFIG_SELECT_ = 'db_course';

    const _DATABASE_ = 'hhz_course';

    const _TABLE_NAME = 'course_order_log';

    const LOG_TYPE_CREATE = 1;
    const LOG_TYPE_PAY_SUCCESS = 2;
    const LOG_TYPE_PAY_ERROR = 3;

    const LOG_DESC = [
        self::LOG_TYPE_CREATE => '创建订单',
        self::LOG_TYPE_PAY_SUCCESS => '支付成功',
        self::LOG_TYPE_PAY_ERROR => '支付失败',
    ];

    public static function selectByWhere($where, $select = '*')
    {
        $list = self::select($select, $where);
        return $list;
    }

    public static function getByWhere($where)
    {
        return self::get('*', $where);
    }

    public static function selectCount($where)
    {
        return self::count($where);
    }

    public static function insertData($data)
    {
        if (!isset($data['addtime'])) {
            $data['addtime'] = date('Y-m-d H:i:s');
        }
        $ret = self::insert($data);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return self::id();
    }

    public static function updateData($data, $where)
    {
        $ret = self::update($data, $where);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return true;
    }

}

